<?php

//登陆控制器
class LoginController extends Controller{
	//登陆
	public function index(){
		if(IS_POST){
			//把模型保存到变量中
			$model=K('Admin');
			//调用模型里面的方法，验证
			if(!$adminInfo = $model->login()){
				$this ->error($model->error);
			}
			//存入SESSION
			$_SESSION['aid'] = $adminInfo['aid'];
			$_SESSION['adminname'] = $adminInfo['adminname'];
			//登陆成功
			$this->success('登陆成功',U('Admin/Index/index'));
		}
		$this->display();
	}
	
	//验证码显示
	public function code(){
		$code = new Code();
		$code -> show();
	}
	
	//退出
	public function out(){
		//清除SESSION
		session(null);
		$this->success('退出成功',U('Admin/Login/index'));
	}
	
}



?>